|
A delegate is a form of type-safe function pointer used by the Common Language Infrastructure (CLI). Delegates specify a method to call and optionally an object to call the method on. Delegates are used, among other things, to implement callbacks and event listeners. A delegate object encapsulates a reference to a method. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked. == C# code example == Code to declare a delegate type, named SendMessageDelegate , which takes a Message as a parameter and returns void : Code to define a method which takes an instantiated delegate as its argument: The implemented method which runs when the delegate is called: Code to call the SendMessage method, passing an instantiated delegate as an argument: 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Delegate (CLI)」の詳細全文を読む スポンサード リンク
|